/*
 * Wire
 * Copyright (C) 2018 Wire Swiss GmbH
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see http://www.gnu.org/licenses/.
 *
 */

// ----------------------------------------------------------------------------
// TEXT
// ----------------------------------------------------------------------------

.ellipsis {
  white-space: pre; // TODO should be nowrap
  overflow: hidden;
  text-overflow: ellipsis;
}

.ellipsis-nowrap {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ellipsis-multiline(@lines) {
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: @lines;
  -webkit-box-orient: vertical;
}

.text-nowrap {
  white-space: nowrap;
}

.text-center {
  text-align: center;
}

.text-left {
  text-align: left;
}

.text-right {
  text-align: right;
}

.text-uppercase {
  text-transform: uppercase;
}

.text-capitalize {
  text-transform: capitalize;
}

.text-underline {
  text-decoration: underline;
}

.no-text-selection() {
  user-select: none;
  cursor: default;
}

.text-selection() {
  user-select: initial;
  cursor: text;
}

.font-antialiasing {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.no-font-antialiasing {
  -webkit-font-smoothing: subpixel-antialiased;
  -moz-osx-font-smoothing: auto;
}

.cursor-pointer {
  cursor: pointer;
}

.cursor-default {
  cursor: default !important;
}

// ----------------------------------------------------------------------------
// Animations
// ----------------------------------------------------------------------------

@keyframes spin {
  to {
    transform: rotate(1turn);
  }
}

.spin {
  animation: spin 1s infinite linear;
}

.spin-slow:extend(.spin) {
  animation-duration: 2.5s;
}

// ----------------------------------------------------------------------------
// GEOM
// ----------------------------------------------------------------------------

.size(@width; @height) {
  width: @width;
  height: @height;
}

.square(@size) {
  .size(@size; @size);
}

.circle(@size) {
  .square(@size);
  border-radius: 50%;
}

.arrow-down::before {
  .icon-mixin('\e111');
  display: inline-block;
  transform: rotate(90deg);
}

// ----------------------------------------------------------------------------
// ALIGNMENT
// ----------------------------------------------------------------------------

.absolute-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.vertical-align() {
  position: relative;
  top: 50%;
  transform: translateY(-50%);
}

.pull-left {
  float: left;
}

.pull-right {
  float: right;
}

// ----------------------------------------------------------------------------
// MISC
// ----------------------------------------------------------------------------

.clear {
  &::after {
    content: '';
    display: table;
    clear: both;
  }
}

.see-through {
  pointer-events: none;
}

.not-see-through {
  pointer-events: auto;
}

.full-screen {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  bottom: 0;
}

.translucent {
  opacity: 0.4;
}

.element-disabled {
  .translucent;
  pointer-events: none;
}

.no-transition() {
  transition: none !important;
}

.hardware-acc {
  -webkit-perspective: 1000;
  -webkit-backface-visibility: hidden;
}

.mirror {
  transform: scaleX(-1);
}

// ----------------------------------------------------------------------------
// VISIBILITY
// ----------------------------------------------------------------------------

.none,
.off,
.hide {
  display: none;
}

.block,
.on,
.show {
  display: block;
}

.hidden {
  visibility: hidden;
}

.visible {
  visibility: visible;
}

// ----------------------------------------------------------------------------
// BACKGROUND HELPERS
// ----------------------------------------------------------------------------

.bg-size(@size) {
  background-size: @size;
  background-position: 50%;
  background-repeat: no-repeat;
}

.bg-cover() {
  .bg-size(cover);
}

.bg-contain() {
  .bg-size(contain);
}

// ----------------------------------------------------------------------------
// BUBBLE
// ----------------------------------------------------------------------------

.bubble-content() {
  display: flex;
  flex-direction: column;
  width: @bubble-width;
  height: @bubble-height;
}

// ----------------------------------------------------------------------------
// ICON MIXINS
// ----------------------------------------------------------------------------

.icon-mixin (@code, @icon-size: 16px) {
  content: @code;
  font-family: Wire;
  speak: none;
  font-size: @icon-size;
  font-style: normal;
  font-weight: normal;
  font-variant: normal;
  text-transform: none;
  line-height: 1;

  /* Better Font Rendering =========== */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

// ----------------------------------------------------------------------------
// ELEMENT RESETS
// ----------------------------------------------------------------------------

.reset-textarea {
  border: none;
  outline: 0;
  padding: 0;
  margin: 0;
  resize: none;
}

.list-unstyled() {
  list-style-type: none;
  padding-left: 0;
}

// ----------------------------------------------------------------------------
// SCROLLBARS
// ----------------------------------------------------------------------------

// creates mac like scrollbar, but only in webkit browsers
.custom-scrollbar() {
  @scrollbar-size: 7px;

  &::-webkit-scrollbar {
    width: @scrollbar-size;
  }

  &::-webkit-scrollbar-track {
    background: none;
  }

  &::-webkit-scrollbar-thumb {
    box-shadow: 0 0 1px #fff;
    background-color: fade(#000, 50%);
    border-radius: @scrollbar-size;
  }
}

.hide-scrollbar() {
  -ms-overflow-style: none;
  overflow: -moz-scrollbars-none;

  &::-webkit-scrollbar {
    display: none !important;
  }
}
